package logic

import (
	"context"
	"errors"
	"user_srv/models/mysql"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderStatusUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderStatusUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderStatusUpdateLogic {
	return &OrderStatusUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderStatusUpdateLogic) OrderStatusUpdate(in *user.OrderStatusUpdateRequest) (*user.OrderStatusUpdateResponse, error) {
	// todo: add your logic here and delete this line
	order := mysql.Order{}
	err := order.OrderUpdateStatus(in.OrderSn, in.OrderStatus)
	if err != nil {
		logx.Info("修改订单状态失败")
		return nil, errors.New("修改订单状态失败")
	}
	return &user.OrderStatusUpdateResponse{}, nil
}
